#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;
int main() {
	string st1;
	getline(cin, st1);
	char ch;
	cin >> ch;
	if (ch >= 'A' && ch <= 'Z')
		ch += 32;
	int count = 0;
	auto it = st1.begin();
	while (it != st1.end())
	{
		if (*it >= 'A' && *it <= 'Z')
			*it += 32;
		if (*it == ch)
			count++;
		// if((*it)+32==ch)
		// count++;
		// else if((*it)-32==ch)
		// count++;
		it++;
	}
	cout << count << endl;
}